import { Controller, Get, Query, Put, Param, Body, Delete } from '@nestjs/common';
import { ApiTags, ApiOperation, ApiResponse } from '@nestjs/swagger';
import { FeedbackService } from './feedback.service';
import { ModuleSwaggerTags } from '~/constants/modules.constant';
import { FeedbackPageDto } from './dto/feedback-page.dto';
import { UpdateFeedbackStatusDto } from './dto/update-feedback-status.dto';
import { StandardPagination } from '~/helper/paginate';
import { FeedbackEntity } from './feedback.entity';
import { FeedbackResponseDto } from './dto/feedback-response.dto';

@ApiTags(ModuleSwaggerTags.FEEDBACK)
@Controller('cms/feedback')
export class FeedbackController {
  constructor(private readonly feedbackService: FeedbackService) {}

  @Get('page')
  @ApiOperation({ summary: '分页查询反馈列表' })
  @ApiResponse({
    status: 200,
    description: '查询成功',
    type: StandardPagination<FeedbackResponseDto>,
  })
  async findPage(@Query() dto: FeedbackPageDto): Promise<StandardPagination<FeedbackEntity>> {
    return await this.feedbackService.findPage(dto);
  }

  @Put(':id/status')
  @ApiOperation({ summary: '更新反馈状态' })
  @ApiResponse({
    status: 200,
    description: '更新成功',
    type: FeedbackResponseDto,
  })
  async updateStatus(
    @Param('id') id: number,
    @Body() dto: UpdateFeedbackStatusDto,
  ): Promise<FeedbackEntity> {
    return await this.feedbackService.updateStatus(id, dto);
  }

  @Delete(':id')
  @ApiOperation({ summary: '删除反馈' })
  @ApiResponse({
    status: 200,
    description: '删除成功',
  })
  async remove(@Param('id') id: number): Promise<void> {
    return await this.feedbackService.remove(id);
  }
}
